<?php

namespace Sensio\Bundle\TrainingBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\TrainingBundle\Converter\CelsiusConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Cookie;

class ConverterController extends Controller
{
    /**
     * @Route( 
     *   name = "converter", 
     *   path = "/convert/{celsius}/fahrenheit.{_format}", 
     *   methods = "GET", 
     *   requirements = { 
     *     "celsius" = "\d+", 
     *     "_format" = "xml|json" 
     *   } 
     * ) 
     * @Template 
     */ 

    public function celsiusAction($celsius) 
    {
        $converter = new CelsiusConverter();

        return array(
            'fahrenheit' => (float)$converter->toFahrenheit($celsius),
            'celsius' => (float)$celsius
        );
    }

}

